#include <iostream>
#define ll long long
#define maxn 100010
#include <algorithm>
using namespace std;
ll int a[maxn], s[maxn] = {0}, k[maxn];
int main()
{
    int t;
    ll int n, q;
    cin >> t;
    while (t)
    {
        t--;
        cin >> n >> q;
        for (ll int i = 1; i <= n; i++)
        {
            cin >> a[i];
            s[i] = s[i - 1] + a[i];
        }
        ll int j = 1;
        for (ll int i = 1; i <= q; i++)
        {
            cin >> k[i];
            for (j = 1; j <= n; j++)
            {
                if (k[i] < a[j])
                {
                    cout << s[j - 1] << " ";
                    break;
                }
                if (j == n && k[i] >= a[j])
                {
                    cout << s[j] << " ";
                }
            }
        }
        cout << "" << endl;
    }
}